<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ShopGoods extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
      Schema::create('shop_goods', function (Blueprint $table) {
          $table->increments('id');
          $table->Integer('type_id')->unsigned();   // 分类id
          $table->Integer('brand_id')->unsigned();  // 品牌id
          $table->string('goods_name', 100);            // 商品名
          $table->string('goods_pic', 255);                 // 商品图片
          $table->decimal('price', 10, 2)->unsigned(); // 商品价格click_num
          $table->tinyInteger('promate')->unsigned();  // 是否促销
          $table->tinyInteger('status')->unsigned();     // 商品状态
          $table->bigInteger('click_num')->unsigned();   // 点击量
          $table->bigInteger('buy_num')->unsigned();     // 销售量
          $table->timestamps();

          $table->foreign('type_id')
              ->references('id')->on('shop_goods_types')
              ->onDelete('cascade');

          $table->foreign('brand_id')
              ->references('id')->on('shop_goods_brands')
              ->onDelete('cascade');
      });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
        Schema::dropIfExists('shop_goods');
    }
}
